package bairui.international.model.domain.jpa;

import com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue;

/**
 *
 * (用户账户)TB_UserAmount
 *
 * @说明
 * <pre>

 * </pre>
 *
 * @see Help_TB_UserAmount#inheritance() 继承体系信息
 *
 */
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate

@javax.persistence.Entity(name="t_userAmount")
@com.lianjing.sh.processing.info.annotation.GenerateInfoModel
@SuppressWarnings("serial")
@com.lianjing.sh.model.common.annotation.Comment("用户账户")
@com.lianjing.sh.processing.info.annotation.InfoComment("用户账户")
public class TB_UserAmount
 extends TBSuper_BaseIDAndTimeAndOrderValue
 implements 
	com.lianjing.sh.model.common.stardard.TableModel<Long>,
	java.io.Serializable

{

	
	
	/**
	 * 必须属性赋值接口
	 */
	public static interface MustProperties{
		/** 用户 */
		public bairui.international.model.domain.jpa.TB_User getUser();
		/** 总积分 */
		public Double getGrade();
	}
	
	/**
	 * 为必须属性赋值
	 */
	public TB_UserAmount properties(MustProperties properties) {
		this.setUser(properties.getUser());
		this.setGrade(properties.getGrade());
		return this;
	}
	
	/**
	 *	必须属性构造函数
	 */
	public TB_UserAmount(MustProperties properties) {
		this.properties(properties);
	}
	
	
	/**
	 * 可选单属性赋值接口
	 */
	public static interface OptionalSingleProperties{
	}
	
	/**
	 * 为可选单属性赋值
	 */
	public TB_UserAmount properties(OptionalSingleProperties properties) {
		return this;
	}
	
	
	
	public TB_UserAmount(MustProperties must, OptionalSingleProperties optionalSingle) {
		this.properties(must);
		this.properties(optionalSingle);
	}
	
	/**
	 * 仅当前必须属性赋值接口
	 */
	public static interface CurrentMustProperties{
		/** 用户 */
		public bairui.international.model.domain.jpa.TB_User getUser();
		/** 总积分 */
		public Double getGrade();
	}
	
	/**
	 * 为仅当前必须属性赋值
	 */
	public TB_UserAmount properties(CurrentMustProperties properties) {
		this.setUser(properties.getUser());
		this.setGrade(properties.getGrade());
		return this;
	}
	
	/**
	 * 仅当前可选单属性赋值接口
	 */
	public static interface CurrentOptionalSingleProperties{
	}
	
	/**
	 * 为仅当前可选单属性赋值
	 */
	public TB_UserAmount properties(CurrentOptionalSingleProperties properties) {
		return this;
	}
	
	public TB_UserAmount(
		@lombok.NonNull com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean,
		CurrentMustProperties mustProperties,
		CurrentOptionalSingleProperties optionalProperties
	) {
		this(bean);
		this.properties(mustProperties);
		this.properties(optionalProperties);
	}
	
	public TB_UserAmount(
		@lombok.NonNull com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean
	) {
		update(bean);
	}
	
	public TB_UserAmount update(com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean){
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		return this;
	}
	
	
	/**
	 * 更新属性内部类
	 */
	public abstract class UpdateProperties {
	
		public UpdateProperties() throws Exception {
			Integer orderValue = getOrderValue(TB_UserAmount.this);
			if(isOverride_getOrderValue){
				TB_UserAmount.this.setOrderValue(orderValue);
			}
	
			bairui.international.model.domain.jpa.TB_User user = getUser(TB_UserAmount.this);
			if(isOverride_getUser){
				TB_UserAmount.this.setUser(user);
			}
	
			Double grade = getGrade(TB_UserAmount.this);
			if(isOverride_getGrade){
				TB_UserAmount.this.setGrade(grade);
			}
		}
	
		public TB_UserAmount up(){
			return TB_UserAmount.this;
		}
	
		/** 排序值 */
		private boolean isOverride_getOrderValue = true;
		public Integer getOrderValue(TB_UserAmount it) throws Exception { 
			isOverride_getOrderValue = false; 
			return null;
		}
		/** 用户 */
		private boolean isOverride_getUser = true;
		public bairui.international.model.domain.jpa.TB_User getUser(TB_UserAmount it) throws Exception { 
			isOverride_getUser = false; 
			return null;
		}
		/** 总积分 */
		private boolean isOverride_getGrade = true;
		public Double getGrade(TB_UserAmount it) throws Exception { 
			isOverride_getGrade = false; 
			return null;
		}
	
	}
	
	
	/**
	 * 构造函数
	 */
	public TB_UserAmount() {
	}
	
	public TB_UserAmount(
		@lombok.NonNull Long id
	) {
		this.setId(id);
	}
	
	public TB_UserAmount(
		@lombok.NonNull TB_UserAmount bean
	) {
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		this.setUser(bean.getUser());
		this.setGrade(bean.getGrade());
	}
	
	

	


	/**
	 * 属性
	 */
	@com.lianjing.sh.model.common.annotation.Comment("用户")
	@com.lianjing.sh.processing.info.annotation.InfoComment("用户")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.OneToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_User user;

	@com.lianjing.sh.model.common.annotation.Comment("总积分")
	@com.lianjing.sh.processing.info.annotation.InfoComment("总积分")
	@javax.persistence.Column(name="grade", nullable=false)
	private Double grade;

	/** get[用户] */
	public bairui.international.model.domain.jpa.TB_User getUser() {
		return this.user;
	}

	/** get[总积分] */
	public Double getGrade() {
		return this.grade;
	}

	/** set[用户] */
	public void setUser(bairui.international.model.domain.jpa.TB_User user) {
		this.user = user;
	}

	/** set[总积分] */
	public void setGrade(Double grade) {
		this.grade = grade;
	}

	public void assignUser(bairui.international.model.domain.jpa.TB_User user) {
		if(null != user){
			user.setUserAmount(this);
		}
		this.setUser(user);
	}
	

	
	
	

	/** take[用户] */
	public bairui.international.model.domain.jpa.TB_User takeUser(){
		if(null == this.user){
			this.user = new bairui.international.model.domain.jpa.TB_User();
		}
		return this.user;
	}
	
	/** must[用户] */
	public bairui.international.model.domain.jpa.TB_User mustUser() {
		return this.user;
	}
	
	

	/**
	 * 复写 hashCode
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		return prime * result + ((this.getId() == null) ? 0 : this.getId().hashCode());
	}
	
	/**
	 * 复写 equals
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj){
			return true;
		}
		if (obj == null){
			return false;
		}
		if (getClass() != obj.getClass()){
			return false;
		}
		TB_UserAmount other = (TB_UserAmount) obj;
		if (this.getId() == null) {
			return false;
		} else if (!this.getId().equals(other.getId())){
			return false;
		}
		return true;
	}
	

	/**
	 * 用来覆盖toString()的输出
	 */
	@javax.persistence.Transient
	private String toString;
	
	public void setToString(String toString) {
		this.toString = toString;
	}
	
	/**
	 * 复写 toString
	 */
	@Override
	public String toString() {
		if(null != this.toString){
			return this.toString;
		}
		return super.toString();
	}	

	@javax.persistence.PrePersist
	public void prePersist() {
		this.setCreateTime(new java.util.Date());
		this.setModifyTime(new java.util.Date());
	}
	
	@javax.persistence.PreUpdate
	public void preUpdate() {
		this.setModifyTime(new java.util.Date());
	}



}
